package com.example.myapplication.utils;

import android.Manifest;
import android.app.Activity;
import android.content.pm.PackageManager;
import android.os.Build;

import com.example.myapplication.App;

import androidx.annotation.RequiresApi;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;

@RequiresApi(api = Build.VERSION_CODES.S)
public class PermissionHelper {

    private static final String[] Permissions = new String[] {
            Manifest.permission.BLUETOOTH,
            Manifest.permission.BLUETOOTH_ADMIN,
            Manifest.permission.BLUETOOTH_CONNECT,
            Manifest.permission.BLUETOOTH_SCAN,
            Manifest.permission.ACCESS_FINE_LOCATION,
            Manifest.permission.ACCESS_COARSE_LOCATION,
            Manifest.permission.FOREGROUND_SERVICE,
    };


    public static void requestPermission(Activity activity) {
        ActivityCompat.requestPermissions(activity, Permissions, 0);
    }
    public static boolean hasPermission() {
        for (String str: Permissions) {
            int res = ContextCompat.checkSelfPermission(App.AppContext, str);
            if (res != PackageManager.PERMISSION_GRANTED)
                return false;
        }
        return true;
    }

}
